From 05bc94043d1bf4a85bafae50a46eb0592f75568f Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 25 Oct 2002 14:48:22 +0000 Subject: [PATCH] Clean up a few missing prototypes, normalize calls to fatal somewhat. --- gpsbabel/cetus.c | 8 ++++---- gpsbabel/defs.h | 17 ++++++++++++++--- gpsbabel/geo.c | 6 +++--- gpsbabel/gpspilot.c | 8 ++++---- gpsbabel/magproto.c | 10 ++++++---- gpsbabel/util.c | 6 +++--- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/gpsbabel/cetus.c b/gpsbabel/cetus.c index 6034475e0..c6b2fe638 100644 --- a/gpsbabel/cetus.c +++ b/gpsbabel/cetus.c @@ -98,11 +98,11 @@ data_read(void) struct pdb_record *pdb_rec; if (NULL == (pdb = pdb_Read(fileno(file_in)))) { - fatal(MYNAME ": pdb_Read failed"); + fatal(MYNAME ": pdb_Read failed\n"); } if ((pdb->creator != MYCREATOR) || (pdb->type != MYTYPE)) { - fatal(MYNAME ": Not a Cetus file."); + fatal(MYNAME ": Not a Cetus file.\n"); } for(pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) { @@ -188,11 +188,11 @@ cetus_writewpt(waypoint *wpt) opdb_rec = new_Record (0, 0, ct++, sizeof(*rec), (const ubyte *)rec); if (opdb_rec == NULL) { - fatal(MYNAME ": libpdb couldn't create record"); + fatal(MYNAME ": libpdb couldn't create record\n"); } if (pdb_AppendRecord(opdb, opdb_rec)) { - fatal(MYNAME ": libpdb couldn't append record"); + fatal(MYNAME ": libpdb couldn't append record\n"); } } diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index f626ea393..4405c384d 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -149,17 +149,24 @@ typedef void (*ff_deinit) (void); typedef void (*ff_read) (void); typedef void (*ff_write) (void); +void fprintdms(FILE *, const coord *, int); + typedef void (*waypt_cb) (const waypoint *); void waypt_add (waypoint *); void waypt_del (waypoint *); -void route_add (waypoint *); void waypt_disp_all(waypt_cb); unsigned int waypt_count(void); -void fprintdms(FILE *, const coord *, int); + +route_head *route_head_alloc(void); +void route_add (waypoint *); +void route_add_wpt(route_head *rte, waypoint *wpt); +void route_add_head(route_head *rte); + char *mkshort (const char *); void setshort_length(int n); void setshort_badchars(const char *); void setshort_mustupper(int n); +void setshort_whitespace_ok(int n); typedef struct ff_vecs { ff_init rd_init; @@ -173,7 +180,11 @@ typedef struct ff_vecs { void waypt_init(void); void route_init(void); void waypt_disp(const waypoint *); -void fatal(const char *, ...); +void fatal(const char *, ...) +#if __GNUC__ + __attribute__ ((__format__ (__printf__, 1, 2))); +#endif + ; ff_vecs_t *find_vec(char *); void disp_vecs(void); void printposn(const coord *c, int is_lat); diff --git a/gpsbabel/geo.c b/gpsbabel/geo.c index 92b039fae..fe2467b8c 100644 --- a/gpsbabel/geo.c +++ b/gpsbabel/geo.c @@ -145,12 +145,12 @@ geo_rd_init(const char *fname) { fd = fopen(fname, "r"); if (fd == NULL) { - fatal(MYNAME ":Can not open %s for reading\n"); + fatal(MYNAME ":Cannot open %s for reading\n", fname); } psr = XML_ParserCreate(NULL); if (!psr) { - fatal(MYNAME ":Can not create XML parser\n"); + fatal(MYNAME ":Cannot create XML parser\n"); } XML_SetElementHandler(psr, geo_start, geo_end); @@ -169,7 +169,7 @@ geo_wr_init(const char *fname) { ofd = fopen(fname, "w"); if (ofd == NULL) { - fatal(MYNAME ":Can not open %s for writing\n"); + fatal(MYNAME ":Cannot open '%s' for writing\n", fname); } } diff --git a/gpsbabel/gpspilot.c b/gpsbabel/gpspilot.c index aebf30d64..f6e508ed8 100644 --- a/gpsbabel/gpspilot.c +++ b/gpsbabel/gpspilot.c @@ -79,11 +79,11 @@ data_read(void) struct pdb_record *pdb_rec; if (NULL == (pdb = pdb_Read(fileno(file_in)))) { - fatal(MYNAME ": pdb_Read failed"); + fatal(MYNAME ": pdb_Read failed\n"); } if ((pdb->creator != MYCREATOR) || (pdb->type != MYTYPE)) { - fatal(MYNAME ": Not a gpspilot file."); + fatal(MYNAME ": Not a gpspilot file.\n"); } for(pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) { @@ -156,11 +156,11 @@ gpspilot_writewpt(waypoint *wpt) opdb_rec = new_Record (0, 2, ct++, vdata-(char *)rec, (const ubyte *)rec); if (opdb_rec == NULL) { - fatal(MYNAME ": libpdb couldn't create record"); + fatal(MYNAME ": libpdb couldn't create record\n"); } if (pdb_AppendRecord(opdb, opdb_rec)) { - fatal(MYNAME ": libpdb couldn't append record"); + fatal(MYNAME ": libpdb couldn't append record\n"); } } diff --git a/gpsbabel/magproto.c b/gpsbabel/magproto.c index 4959d0050..1e83489ba 100644 --- a/gpsbabel/magproto.c +++ b/gpsbabel/magproto.c @@ -426,7 +426,7 @@ terminit(const char *portname) FORMAT_MESSAGE_IGNORE_INSERTS, NULL,GetLastError(),0, (LPTSTR) &buf,0,NULL); - fatal(MYNAME ": '%s' cannot be opened. %s", portname, buf); + fatal(MYNAME ": '%s' cannot be opened. %s\n", portname, buf); } tio.DCBlength = sizeof(DCB); GetCommState (comport, &tio); @@ -450,7 +450,7 @@ terminit(const char *portname) if (!SetCommState (comport, &tio)) { CloseHandle(comport); - fatal(MYNAME ": set port settings"); + fatal(MYNAME ": set port settings\n"); } GetCommTimeouts (comport, &timeout); @@ -459,7 +459,7 @@ terminit(const char *portname) timeout.WriteTotalTimeoutConstant = 1000; if (!SetCommTimeouts (comport, &timeout)) { CloseHandle (comport); - fatal(MYNAME ": set timeouts"); + fatal(MYNAME ": set timeouts\n"); } } @@ -495,7 +495,7 @@ termwrite(char *obuf, int size) } WriteFile (comport, obuf, size, &len, NULL); if (len != size) { - fatal(MYNAME ":. Wrote %d of %d bytes.", len, size); + fatal(MYNAME ":. Wrote %d of %d bytes.\n", len, size); } } @@ -933,6 +933,8 @@ mag_waypt_pr(const waypoint *waypointp) case gt_virtual: icon_token = mag_find_token_from_descr("Virtual cache"); break; + default: + break; } owpt = global_opts.synthesize_shortnames ? diff --git a/gpsbabel/util.c b/gpsbabel/util.c index e5f4f3682..b74767862 100644 --- a/gpsbabel/util.c +++ b/gpsbabel/util.c @@ -29,7 +29,7 @@ xmalloc(size_t size) void *obj = malloc(size); if (!obj) { - fatal("gpsbabel: Unable to allocate %d bytes of memory.\n"); + fatal("gpsbabel: Unable to allocate %d bytes of memory.\n", size); } return obj; @@ -41,7 +41,7 @@ xcalloc(size_t nmemb, size_t size) void *obj = calloc(nmemb, size); if (!obj) { - fatal("gpsbabel: Unable to allocate %d bytes of memory.\n"); + fatal("gpsbabel: Unable to allocate %d bytes of memory.\n", size); } return obj; @@ -53,7 +53,7 @@ xstrdup(const char *s) char *o = strdup(s); if (!o) { - fatal("gpsbabel: Unable to allocate %d bytes of memory.\n"); + fatal("gpsbabel: Unable to allocate %d bytes of memory.\n", strlen(s)); } return o; -- 2.30.2